#include <stdio.h>

int main()
{
	int i = 0;
	int j = 0;
	int s = 0;
	int n = 0;
	int m = 0;
	scanf("%d %d", &n, &m);
	int arr1[n];
	int arr2[m];
	int arr3[m + n];
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr1[i]);
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d", &arr2[i]);
	}
	i = 0;
	j = 0;
	while (i < n && j < m)
	{
		if (arr1[i] < arr2[j])
		{
			arr3[s] = arr1[i];
			s++;
			i++;
		}
		else
		{
			arr3[s] = arr2[j];
			j++;
			s++;
		}
	}
	while (i < n)
	{
		arr3[s] = arr1[i];
		s++;
		i++;
	}
	while (j < m)
	{
		arr3[s] = arr2[j];
		s++;
		j++;
	}
	for (i = 0; i < m + n; i++)
	{
		printf("%d ", arr3[i]);
	}
	return 0;
}



